<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<script type="text/javascript">
function moreBuybook(){
	location.href="book_buybook_list.do";
}
function moreSalebook(){
	location.href="book_salebook_list.do";
}
function showPhone(id,sessionMvo){
	var condition="width=400, height=350, top=100,left=1480";
	if(sessionMvo==""){
		alert("로그인하셔야 이용 가능합니다.");
		return false;
	}
	window.open("auth_findById.do?id="+id,"휴대폰 번호",condition);
}
function sendMsg(sessionMvo,recId,title,version,price,bookType){
	var bookInfo = "책제목 : "+ title + " / " + "개정정보 : " + version + " / " + "희망가격 : " + price + "원";
	if(sessionMvo==""){
		alert("로그인하셔야 이용 가능합니다.");
		return false;
	}	
	
	var sessionStatus='${sessionScope.mvo.id }';
	if(sessionStatus==recId){
		alert("본인 상품은 Pick 하실 수 없습니다");
		return false;
	}	
	
	$.ajax({
		url:"auth_sendMsg.do",
		data:"recId="+recId+"&bookInfo="+encodeURIComponent(bookInfo)+"&bookType="+encodeURIComponent(bookType),
		success:function(data){
			alert("Pick 메시지 전송을 성공하였습니다.");
		},
		error:function(xhr,status,error){
			alert("전송 실패 : "+status.error);
		}
	});//ajax
}
</script>


	<img src="${initParam.root }img/bg_main.jpg"><br><br>
	<center>
	<table cellpadding="5">
		<tr>
			<td align="center" width="500px">
				<a href="book_salebook_list.do"><img src="${initParam.root }img/title_salebook.png"></a>
			</td>
			<td align="center" width="500px">
				<a href="book_buybook_list.do"><img src="${initParam.root }img/title_buybook.png"></a>
			</td>
		</tr>
		<tr>
			<td align="center">
				<table>
					<c:forEach var="sbvo" items="${requestScope.salebooklvo.list}" begin="0" end="4">
						<tr><td colspan="3"><hr></td></tr>
						<tr>
							<td width="100px" align="center"><img src="${sbvo.image }" width="80px"></td>
							<td width="300px"><b><font color='#ED4C00'>${sbvo.mvo.uvo.univ }</font><br>${sbvo.title }</b><br>
								${sbvo.writer }&nbsp;&nbsp;|&nbsp; ${sbvo.publisher }&nbsp;&nbsp;|&nbsp;
								${sbvo.version }&nbsp;&nbsp;|&nbsp; ${sbvo.status }<br>
								${sbvo.price }원
							</td>
							<td width="110px" align="center"><input type="button" id="pickBtn" value="Pick !" style="width:100px; height:27px; color:white; background-color:#4374D9; margin-bottom: 5px"
						title="상품 판매자에게 Pick 메시지를 보낼 수 있습니다." onclick="sendMsg('${sessionScope.mvo }','${sbvo.mvo.id }','${sbvo.title }','${sbvo.version }','${sbvo.price }','판매도서')"><br>
				<input type="button" id="phoneBtn" value="판매자 휴대폰" style="width:100px;"
						title="상품 판매자의 휴대폰 번호를 확인하세요." onclick="showPhone('${sbvo.mvo.id}','${sessionScope.mvo }')"> </td>
						</tr>
					</c:forEach>
					<tr><td colspan="3"><hr></td></tr>
					<tr><td colspan="3" align="center"><input type="button" value="더보기" id="moreSalebookBtn" onclick="moreSalebook()" style="width:450px; height:40px;"></td></tr>
				</table>
			</td>
			<td align="center">
				<table>
					<c:forEach var="bbvo" items="${requestScope.buybooklvo.list}" begin="0" end="4">
						<tr><td colspan="3"><hr></td></tr>
						<tr>
							<td width="100px" align="center"><img src="${bbvo.image }" width="80px"></td>
							<td width="300px"><b><font color='#ED4C00'>${bbvo.mvo.uvo.univ }</font><br>${bbvo.title }</b><br>
								${bbvo.writer }&nbsp;&nbsp;|&nbsp; ${bbvo.publisher }&nbsp;&nbsp;|&nbsp;
								${bbvo.version }&nbsp;&nbsp;|&nbsp; ${bbvo.status }<br>
								${bbvo.price }원
							</td>
							<td width="110px" align="center"><input type="button" id="pickBtn" value="Pick !" style="width:100px; height:27px; color:white; background-color:#4374D9; margin-bottom: 5px"
						title="상품 구매자에게 Pick 메시지를 보낼 수 있습니다." onclick="sendMsg('${sessionScope.mvo }','${bbvo.mvo.id }','${bbvo.title }','${bbvo.version }','${bbvo.price }','희망도서')"><br>
				<input type="button" id="phoneBtn" value="구매자 휴대폰" style="width:100px;"
						title="상품 구매자의 휴대폰 번호를 확인하세요." onclick="showPhone('${bbvo.mvo.id}','${sessionScope.mvo }')"> </td>
						</tr>
					</c:forEach>
					<tr><td colspan="3"><hr></td></tr>
					<tr><td colspan="3" align="center"><input type="button" value="더보기" id="moreBuybookBtn" onclick="moreBuybook()" style="width:450px; height:40px;"></td></tr>
				</table>
			</td>
		</tr>
	</table>
	</center>
